"use strict";

const {src, dest, watch, series} = require("gulp");
const less = require('gulp-less');
const concatCss = require('gulp-concat-css');
const rename = require('gulp-rename');
const cleanCSS = require('gulp-clean-css');
const paths = {
    styles: {
        src: 'src/styles/style.less',
        dest: 'dist/styles/'
    }
};

function compilerLess() {
    return src(paths.styles.src)
        .pipe(less())
        .pipe(concatCss("style.css"))
        .pipe(cleanCSS())
        .pipe(rename({
            basename: 'style',
            suffix: '.min'
        }))
        .pipe(dest(paths.styles.dest))
}

exports.less = compilerLess;

exports.watch = function () {
    watch(paths.styles.src, series('less'));
};